import { ComponentType } from '@/plugins/form-render/constants/component-types';
import { IGaeaSetting } from '@/plugins/form/defines/application';
// import { TRAVEL_DEFAULT_URL } from '../constants';
// 差旅费报销申请
export class Props {
  // public baseUrl = TRAVEL_DEFAULT_URL;
  // public workplaceId = TRAVEL_DEFAULT_URL.workplaceList;
  // public travelPlanId = TRAVEL_DEFAULT_URL.travelPlanList;
  // public travelPlanDetailsId = TRAVEL_DEFAULT_URL.travelPlanDetails;
  public form?: any;
  public renderMode?: string;
  public name?: string;
  public setChildHandlers?: (params: any) => void;
  public GaeaOnPropsCallback?: (prams: any) => {};

  public editSetting: IGaeaSetting = {
    key: 'gaea-group-labor-outsider-declare',
    name: 'GroupLaborOutSiderDeclare',
    isGroup: true,
    grouping: 'laborType',
    // editors: TRAVEL_COST_EDITORS,
    defaultEvents: [
      // 监听-关联项目编号点击触发
      {
        trigger: {
          type: 'subscribe',
          name: 'gaea_relateProject_change',
        },
        action: {
          type: 'childHandler',
          field: 'onRelateProjectChange',
        },
      },
      // 监听-关联事项点击触发
      {
        trigger: {
          type: 'subscribe',
          name: 'gaea_relateEvent_change',
        },
        action: {
          type: 'childHandler',
          field: 'onRelateEventChange',
        },
      },
      // 监听-总额变化
      {
        trigger: {
          type: 'subscribe',
          name: 'gaea_totalAmount_change',
        },
        action: {
          type: 'childHandler',
          field: 'onTotalAmountChange',
        },
      },
    ],
    components: [
      {
        key: ComponentType.RadioSelect,
        props: {
          name: '关联项目',
          code: 'projectId',
          required: true,
          type: 'modal',
          // options: WORKPLACE_LIST,
        },
        defaultEvents: [
          {
            trigger: {
              type: 'callback',
              field: 'onChange',
            },
            action: {
              type: 'emit',
              name: 'gaea_relateProject_change',
            },
          },
        ],
      },
      {
        key: ComponentType.RadioSelect,
        props: {
          name: '项目属性',
          code: 'projectAttr',
          required: true,
          disabled: true,
          type: 'modal',
          placeholder: '根据关联项目自动填写',
          // options: COST_CATEGORY_LIST
        },
        defaultEvents: [
          {
            trigger: {
              type: 'callback',
              field: 'onChange',
            },
            action: {
              type: 'emit',
              name: 'gaea_projectAttr_change',
            },
          },
        ],
      },
      {
        key: ComponentType.RadioSelect,
        props: {
          name: '费别',
          code: 'costType',
          required: true,
          notFoundContent: '暂无费别',
          // options: COST_CATEGORY_LIST
        },
        defaultEvents: [
          {
            trigger: {
              type: 'callback',
              field: 'onChange',
            },
            action: {
              type: 'emit',
              name: 'gaea_travelPlan_change',
            },
          },
        ],
      },
      {
        key: ComponentType.RadioSelect,
        props: {
          name: '二级费别',
          code: 'secondCostType',
          required: false,
          notFoundContent: '暂无二级费别',
          visibleConditions: [
            {
              componentType: ComponentType.RadioSelect,
              conditionName: 'costType', // 控制 二级费别 显示隐藏的依赖字段
              conditionValue: false,
            },
          ],
          // options: COST_CATEGORY_LIST
        },
      },
      {
        key: ComponentType.TextInput,
        props: {
          name: '摘要',
          code: 'contentAbstract',
          required: true,
          placeholder: '请输入摘要',
        },
      },
      // {
      //   key: ComponentType.RadioSelect,
      //   props: {
      //     name: '关联事项',
      //     code: 'matterId',
      //     required: true,
      //     type: 'modal',
      //     placeholder: '请选择'
      //   },
      //   defaultEvents: [
      //     {
      //       trigger: {
      //         type: 'callback',
      //         field: 'onChange'
      //       },
      //       action: {
      //         type: 'emit',
      //         name: 'gaea_relateEvent_change'
      //       }
      //     }
      //   ]
      // },

      {
        key: ComponentType.RelatedMattersTable,
        props: {
          name: '关联事项',
          code: 'relatedMattersAddList',
          //     code: 'matterId',
          layout: 'table',
          required: true,
          matterId: '',
        },
      },
      // {
      //   key: ComponentType.RadioSelect,
      //   props: {
      //     name: '关联公文',
      //     code: 'documentId',
      //     disabled: true,
      //     type: 'modal',
      //     options: [],
      //     // required: true,
      //     placeholder: '选择关联事项后带入'
      //   }
      // },
      {
        key: ComponentType.FilePicker,
        props: {
          name: '附件',
          code: 'file',
          multiple: true,
          required: false,
        },
      },
      {
        key: ComponentType.LaberDetail,
        props: {
          name: '发放明细',
          code: 'provideItemAddList',
          layout: 'table',
          required: true,
          // matterId: ''
        },
      },
      {
        key: ComponentType.InputMoney,
        props: {
          name: '发放总额',
          code: 'totalAmount',
          required: true,
          placeholder: '根据发放明细中的发放金额自动计算',
        },
        defaultEvents: [
          {
            trigger: {
              type: 'callback',
              field: 'onChange',
            },
            action: {
              type: 'emit',
              name: 'gaea_totalAmount_change',
            },
          },
        ],
      },
      {
        key: ComponentType.TextInput,
        props: {
          name: '发放总额大写',
          code: 'totalAmountText',
          required: true,
          disabled: true,
          placeholder: '根据发放明细中的发放金额自动计算',
        },
      },
    ],
  };

  public children: React.ReactElement[] = [];
  public formValues?: any;
}

export class State {
  matterIdList?: any[];
}
